import time

from Base.Base import Base
from selenium.webdriver.common.by import By

class Page(Base):
    #断言1：判断百度网址正确打开,定义'hao123'
    dy1_loc=(By.XPATH,'/html/body/div[1]/div[1]/div[3]/a[2]')
    def dy1(self):
        return self.find_element(self.dy1_loc).text

    #定位到搜索框,并且点击,输入  '我喜欢软件测试'
    search_loc=(By.XPATH,'/html/body/div[1]/div[1]/div[6]/div/div/div[2]/div/div/div[1]/div/div[1]/div[4]/div[1]')
    def search(self):
        self.send_keys(self.search_loc,'我喜欢软件测试')

    #断言4：'我喜欢软件测试'
    dy4_loc=(By.XPATH,'/html/body/div[3]/div[1]/div[6]/div/div/div[2]/div[2]/div/div/div/div[1]/div[4]/div[1]/div[2]/textarea')
    def dy4(self):
        return self.find_element(self.dy4()).text


    #点击搜索
    sousuo_loc=(By.XPATH,'/html/body/div[1]/div[1]/div[6]/div/div/div[2]/div/div/div[1]/div/div[1]/div[4]/div[1]/div[3]/div[3]/button')
    def sousuo(self):
        self.click(self.sousuo_loc)
        time.sleep(5)
    #断言5：搜索之后的页面，断言'筛选'
    dy5_loc=(By.XPATH,'/html/body/div[3]/div[2]/div/div/span')
    def dy5(self):
        return self.find_element(self.dy5()).text


    #断言2 ：判断页面是否含有搜索的关键字
    dy2_loc=(By.XPATH,'/html/body/div[3]/div[3]/div[1]/div[3]/div[1]/div/div/div[1]/div/div/div/div[1]/h3/div/a')
    def dy2(self):
        return self.find_element(self.dy2_loc).text

    #定位点击第二页元素
    two_loc=(By.XPATH,'/html/body/div[3]/div[3]/div[2]/div/div/a[1]/span')
    def two(self):
        self.click(self.two_loc)

    #断言3：判断页面是否含有搜索的关键字
    dy3_loc=(By.XPATH,'/html/body/div[3]/div[3]/div[1]/div[3]/div[1]/div/div/div/div/div[1]/div/div/h3/div/a')
    def dy3(self):
        return self.find_element(self.dy3_loc).text

    #点击更多
    gd_loc=(By.XPATH,'/html/body/div[1]/div[1]/div[3]/div/a')
    def gd(self):
        self.click(self.gd_loc)